package com.java;

import com.java.dao.impl.StudentDaoImpl;
import com.java.entity.Student;
import org.junit.jupiter.api.Test;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

/**
 * TODO
 *
 * @author 村头老杨头
 * @version 1.0
 * @date 2021/9/26 11:44
 */
public class TestJDBC {
    @Test
    public void getStudent() throws SQLException, ClassNotFoundException {
        StudentDaoImpl studentDao = new StudentDaoImpl();
        Student studentById = studentDao.getStudentById("101");
        System.out.println(studentById);
    }
    @Test
    public void listStudentAll() throws SQLException, ClassNotFoundException {
        StudentDaoImpl studentDao = new StudentDaoImpl();
        List<Student> studentList = studentDao.getStudentList();
        for (Student student : studentList) {
            System.out.println(student);
        }
    }
    @Test
    public void addStudent() throws SQLException, ClassNotFoundException {
        Student student = new Student("111", "李小龙", "男", new Date(), "9527");
        StudentDaoImpl studentDao = new StudentDaoImpl();
        studentDao.addStudent(student);

    }
    @Test
    public void updateStudent() throws SQLException, ClassNotFoundException {
        Student student = new Student("111", "李小璐", "女", new Date(), "9527");
        StudentDaoImpl studentDao = new StudentDaoImpl();
        studentDao.updateStudent(student);
    }
    @Test
    public void delStudent() throws SQLException, ClassNotFoundException {
        StudentDaoImpl studentDao = new StudentDaoImpl();
        studentDao.deleteStudent("111");
    }
}
